<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>ActiveRecord::Result</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/github.css" type="text/css" media="screen" />
<script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Class</span> 
            ActiveRecord::Result 
            
                <span class="parent">&lt; 
                    
                    <a href="../Object.html">Object</a>
                    
                </span>
            
        </h1>
        <ul class="files">
            
            <li><a href="../../files/activerecord/lib/active_record/result_rb.html">activerecord/lib/active_record/result.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  
    <div class="description">
      
<p>This class encapsulates a <a href="Result.html">Result</a> returned from
calling <code>exec_query</code> on any database connection adapter. For
example:</p>

<pre class="ruby"><span class="ruby-identifier">x</span> = <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">connection</span>.<span class="ruby-identifier">exec_query</span>(<span class="ruby-string">'SELECT * FROM foo'</span>)
<span class="ruby-identifier">x</span> <span class="ruby-comment"># =&gt; #&lt;ActiveRecord::Result:0xdeadbeef&gt;</span>
</pre>

    </div>
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>#</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Result.html#method-i-5B-5D">[]</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>E</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Result.html#method-i-each">each</a>,
              </li>
            
              
              <li>
                <a href="Result.html#method-i-empty-3F">empty?</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>I</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Result.html#method-i-initialize_copy">initialize_copy</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>L</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Result.html#method-i-last">last</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>N</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Result.html#method-c-new">new</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>T</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Result.html#method-i-to_ary">to_ary</a>,
              </li>
            
              
              <li>
                <a href="Result.html#method-i-to_hash">to_hash</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  
    <!-- Includes -->
    <div class="sectiontitle">Included Modules</div>
    <ul>
      
        <li>
          
            <a href="../Enumerable.html">
              Enumerable
            </a>
          
        </li>
      
    </ul>
  



  

    

    

    


    
      <!-- Section attributes -->
      <div class="sectiontitle">Attributes</div>
      <table border='0' cellpadding='5'>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [R]
            </td>
            <td class='attr-name'>column_types</td>
            <td class='attr-desc'></td>
          </tr>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [R]
            </td>
            <td class='attr-name'>columns</td>
            <td class='attr-desc'></td>
          </tr>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [R]
            </td>
            <td class='attr-name'>rows</td>
            <td class='attr-desc'></td>
          </tr>
        
      </table>
    


    <!-- Methods -->
    
      <div class="sectiontitle">Class Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-c-new">
            
              <b>new</b>(columns, rows, column_types = {})
            
            <a href="Result.html#method-c-new" name="method-c-new" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-new_source')" id="l_method-c-new_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9e4c41c903e8e58721f2c41776a8c60ddba7a0a9/activerecord/lib/active_record/result.rb#L13" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-new_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/result.rb, line 13</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">initialize</span>(<span class="ruby-identifier">columns</span>, <span class="ruby-identifier">rows</span>, <span class="ruby-identifier">column_types</span> = {})
  <span class="ruby-ivar">@columns</span>      = <span class="ruby-identifier">columns</span>
  <span class="ruby-ivar">@rows</span>         = <span class="ruby-identifier">rows</span>
  <span class="ruby-ivar">@hash_rows</span>    = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@column_types</span> = <span class="ruby-identifier">column_types</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                  
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-5B-5D">
            
              <b>[]</b>(idx)
            
            <a href="Result.html#method-i-5B-5D" name="method-i-5B-5D" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-5B-5D_source')" id="l_method-i-5B-5D_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9e4c41c903e8e58721f2c41776a8c60ddba7a0a9/activerecord/lib/active_record/result.rb#L40" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-5B-5D_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/result.rb, line 40</span>
<span class="ruby-keyword">def</span> <span class="ruby-operator">[]</span>(<span class="ruby-keyword ruby-title">idx</span>)
  <span class="ruby-identifier">hash_rows</span>[<span class="ruby-identifier">idx</span>]
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-each">
            
              <b>each</b>()
            
            <a href="Result.html#method-i-each" name="method-i-each" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-each_source')" id="l_method-i-each_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9e4c41c903e8e58721f2c41776a8c60ddba7a0a9/activerecord/lib/active_record/result.rb#L20" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-each_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/result.rb, line 20</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">each</span>
  <span class="ruby-identifier">hash_rows</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">row</span><span class="ruby-operator">|</span> <span class="ruby-keyword">yield</span> <span class="ruby-identifier">row</span> }
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-empty-3F">
            
              <b>empty?</b>()
            
            <a href="Result.html#method-i-empty-3F" name="method-i-empty-3F" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns true if there are no records.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-empty-3F_source')" id="l_method-i-empty-3F_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9e4c41c903e8e58721f2c41776a8c60ddba7a0a9/activerecord/lib/active_record/result.rb#L32" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-empty-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/result.rb, line 32</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">empty?</span>
  <span class="ruby-identifier">rows</span>.<span class="ruby-identifier">empty?</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-initialize_copy">
            
              <b>initialize_copy</b>(other)
            
            <a href="Result.html#method-i-initialize_copy" name="method-i-initialize_copy" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-initialize_copy_source')" id="l_method-i-initialize_copy_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9e4c41c903e8e58721f2c41776a8c60ddba7a0a9/activerecord/lib/active_record/result.rb#L48" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-initialize_copy_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/result.rb, line 48</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">initialize_copy</span>(<span class="ruby-identifier">other</span>)
  <span class="ruby-ivar">@columns</span>   = <span class="ruby-identifier">columns</span>.<span class="ruby-identifier">dup</span>
  <span class="ruby-ivar">@rows</span>      = <span class="ruby-identifier">rows</span>.<span class="ruby-identifier">dup</span>
  <span class="ruby-ivar">@hash_rows</span> = <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-last">
            
              <b>last</b>()
            
            <a href="Result.html#method-i-last" name="method-i-last" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-last_source')" id="l_method-i-last_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9e4c41c903e8e58721f2c41776a8c60ddba7a0a9/activerecord/lib/active_record/result.rb#L44" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-last_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/result.rb, line 44</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">last</span>
  <span class="ruby-identifier">hash_rows</span>.<span class="ruby-identifier">last</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-to_ary">
            
              <b>to_ary</b>()
            
            <a href="Result.html#method-i-to_ary" name="method-i-to_ary" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-to_ary_source')" id="l_method-i-to_ary_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9e4c41c903e8e58721f2c41776a8c60ddba7a0a9/activerecord/lib/active_record/result.rb#L36" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-to_ary_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/result.rb, line 36</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">to_ary</span>
  <span class="ruby-identifier">hash_rows</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-to_hash">
            
              <b>to_hash</b>()
            
            <a href="Result.html#method-i-to_hash" name="method-i-to_hash" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-to_hash_source')" id="l_method-i-to_hash_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9e4c41c903e8e58721f2c41776a8c60ddba7a0a9/activerecord/lib/active_record/result.rb#L24" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-to_hash_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/result.rb, line 24</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">to_hash</span>
  <span class="ruby-identifier">hash_rows</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    